#include "AiringControlPointListCmd.h"

AiringControlPointListCmd::AiringControlPointListCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::ZigbeeControlProtocol;
    this->m_functionCode = FunctionCode;
}

Package AiringControlPointListCmd::toPackage()
{
    Package package;
    QByteArray body;
    QByteArray mac;
    QByteArray nwk;
    for(int i=0;i<8;i++)
    {
        mac.append(0xff);
    }
    nwk.append(0xff);
    nwk.append(0xff);
    body.append(mac);
    body.append(nwk);

    body.append(m_ControlList.size());
foreach(const ControlPointStruct &Controlpointstruct,m_ControlList)
{
        body.append(Controlpointstruct.address() & 0xFF);
        body.append(Controlpointstruct.address() >> 8);
        body.append(Controlpointstruct.value() & 0xFF);
        body.append(Controlpointstruct.value() >> 8);
}
    package.setFunction(FunctionCode);
    package.setBody(body);
    return package;
}

void AiringControlPointListCmd::unPackage(Package package)
{
    Q_UNUSED(package);
}
QList<ControlPointStruct> AiringControlPointListCmd::controlList()
{
    return m_ControlList;
}
void AiringControlPointListCmd::setControlList(const QList<ControlPointStruct> ControlList)
{
    m_ControlList=ControlList;
}
